export const directives = [
  {
    name: 'drag',
    config: {
      mounted(el) {
        el.style.position = 'absolute'
        let flag = false
        const parentEl = el.parentNode
        const parentElOffsetLeft = parentEl.offsetLeft
        const parentElOffsetTop = parentEl.offsetTop + 58

        let offsetX = 0,
          offsetY = 0
        console.log(parentElOffsetLeft, parentElOffsetTop)
        el.addEventListener('mousedown', (e) => {
          flag = true
          offsetX = e.offsetX
          offsetY = e.offsetY
        })
        document.addEventListener('mousemove', (e) => {
          if (flag) {
            el.style.left = e.pageX - parentElOffsetLeft - offsetX + 'px'
            el.style.top = e.pageY - parentElOffsetTop - offsetY + 'px'
          }
        })
        document.addEventListener('mouseup', () => {
          flag = false
        })
      }
    }
  }
]
